<?php 
$Content = QContext::instance();
$base_url = $Content->requestUDI();
$search = $base_url;
$search['action'] = 'search';
$delete = $base_url;
$delete['action'] = 'del';
$add = $base_url;
$add['action'] = 'add';
$import = $base_url;
$import['action'] = 'import';
$output = $base_url;
$output['action'] = 'output';
$change = $base_url;
$change['action'] = 'change';
$make = $base_url;
$make['action'] = 'make';
?>
<form id="pagerForm" method="get" action="<?php echo url($base_url,null,null,array('mode'=>'standard'));?>">
		<input type="hidden" name="pageNum" value="<?php echo $pagination['current'];?>" /> <!--【必须】value=1可以写死-->
		<input type="hidden" name="numPerPage" value="<?php echo $pagination['page_size'];?>" /> <!--【可选】每页显示多少条-->
		<input type="hidden" name="orderField" value="<?php echo $orderField;?>" />
		<input type="hidden" name="orderDirection" value="<?php echo $orderDirection;?>" />
</form>

<div class="pageHeader">
	<form rel="pagerForm" onsubmit="return navTabSearch(this);" action="<?php echo url($base_url,null,null,array('mode'=>'standard'));?>" method="get">
	<div class="searchBar">
		<table class="searchContent">
			<tr>
				<td>
				<label>账号：</label>
				<input type="text" name="acctname" value="<?php echo isset($param['acctname'])?$param['acctname']:'';?>"/>
				<input type="hidden" name="_querymethod[acctname]" value="like">
				</td>
				<td>
				<label>状态：</label>
				<select class="combox" name="enable">
				<option value="1" <?php echo isset($param['enable'])?$param['enable']=='1'?'selected':'':'';?>>正常</option>
				<option value="0" <?php echo isset($param['enable'])?$param['enable']=='0'?'selected':'':'';?>>锁定</option>
				</select>
				</td>
			<td>
				<label>所属代理：</label>
				<select name="agent_id">
				<option value="">请选择代理....</option>
				<?php foreach ($agent_list as $k=>$v):?>
				<option value="<?php echo $k;?>" <?php echo isset($param['agent_id'])?$param['agent_id'] == $k?'selected':'':''; ?>><?php echo $v;?></option>
				<?php endforeach;?>
				</select>
			</td>
			
			<td>
				<label>SIP前缀：</label>
				<input type="text" name="bindexten_sip" value="<?php echo isset($param['bindexten_sip'])?$param['bindexten_sip']:'';?>"/>
				<input type="hidden" name="_querymethod[bindexten_sip]" value="like">
			</td>
			</tr>
			<tr>
				<td>
				<label>过期时间：</label>
      			<input type="text" name="expireddate_begin" class="date" value="<?php echo isset($param['expireddate_begin'])?$param['expireddate_begin']:'';?>" />
      			
				</td>
				<td>
				<label>至：</label>
      			<input type="text" name="expireddate_end" class="date" value="<?php echo isset($param['expireddate_end'])?$param['expireddate_end']:'';?>"  />
				</td>
				<td>
				<label>激活时间：</label>
      			<input type="text" name="activedate_begin" class="date" value="<?php echo isset($param['activedate_begin'])?$param['activedate_begin']:'';?>" />
      			
				</td>
				<td>
				<label>至：</label>
      			<input type="text" name="activedate_end" class="date" value="<?php echo isset($param['activedate_end'])?$param['activedate_end']:'';?>" />
				</td>
			</tr>
			<tr>
				<td>
				<label>余额：</label>
      			<input type="text" name="balance_begin" class="number" value="<?php echo isset($param['balance_begin'])?$param['balance_begin']:'';?>"/>
      			
				</td>
				<td>
				<label>至：</label>
      			<input type="text" name="balance_end" class="number"  value="<?php echo isset($param['balance_end'])?$param['balance_end']:'';?>"/>
				</td>
				<td>
				<label>已使用金额：</label>
      			<input type="text" name="costbalance_begin" class="number"  value="<?php echo isset($param['costbalance_begin'])?$param['costbalance_begin']:'';?>"/>
      			
				</td>
				<td>
				<label>至：</label>
      			<input type="text" name="costbalance_end" class="number"  value="<?php echo isset($param['costbalance_end'])?$param['costbalance_end']:'';?>"/>
				</td>
			</tr>
			<tr>
				
			</tr>
		</table>
		
		<div class="subBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>
				<li><a class="button" target="dwzExport" title="是否导出数据" href="<?php echo url($output)?>" ><span>导出查询结果</span></a></li>
				<li><a class="button" href="<?php echo url($change,null,null,array('mode'=>'standard'));?>" target="dialog" mask="true" title="查询框" width="500" height="500"><span>查询批量修改</span></a></li>
				<iframe id="output" name="output" src="" width=0 height=0></iframe>
			</ul>
		</div>
	</div>
	</form>
</div>
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
			<?#php// if ($_SESSION['acct']['admin_id'] == -1 && $_SESSION['acct']['agent_id'] == -1):?>
			<li><a title="确认删除选择的用户数据,此操作将不能恢复?" target="selectedTodo" rel="ids[]" href="<?php echo url($delete)?>" class="delete"><span>批量删除</span></a></li>
			
			<li class="line">line</li>
			<?#php// endif;?>
			<li><a class="edit" href="<?php echo url($add)?>/id/{id}" target="dialog" height="500" warn="请选择一个产品"><span>修改</span></a></li>
			<?php if ($_SESSION['acct']['admin_id'] == -1 && $_SESSION['acct']['agent_id'] == -1):?>
			<li class="line">line</li>
			<li><a class="edit" href="<?php echo url($add)?>/" target="dialog" rel="添加用户" height="500" warn="请选择一个产品"><span>添加用户</span></a></li>
			<li class="line">line</li>
			<li><a class="edit" href="<?php echo url($make);?>/" target="dialog" rel="生成用户" height="500" ><span>生成用户</span></a></li>
			<li class="line">line</li>
			
			<?php endif;?>
			<li><a class="edit" href="<?php echo url($import);?>/" target="dialog" rel="导入用户" height="500" ><span>导入用户</span></a></li>
			<li class="line">line</li>
			<li><a title="确认批量开通VIP?" target="selectedTodo" rel="ids[]" href="<?php echo url('users/batvips')?>/flag/0" class="delete"><span>批量开通VIP</span></a></li>
			<li class="line">line</li>
			<li><a title="确认批量取消VIP?" target="selectedTodo" rel="ids[]" href="<?php echo url('users/batvips')?>/flag/1" class="delete"><span>批量取消VIP</span></a></li>
			<li class="line">line</li>

		</ul>
	</div>
	<table class="table" width="1200" layoutH="195">
		<thead>
			<tr>
				<th width="1%"><input type="checkbox" group="ids[]" class="checkboxCtrl"></th>
				<th width="5%" orderField="agent_id" >代理</th>
				<th width="5%" orderField="acctname" >账号</th>
				<th width="5%" >密码</th>
				<th width="10%" >属性</th>
				<th width="3%" >小号(主叫验证)</th>
				
				<th width="3%" orderField="enable">状态</th>
				<th width="5%" align="center" orderField="balance">话费(元)</th>
				<th width="10%" >增值业务</th>
				<th width="5%" >注册日期/过期日期</th>
				<th width="5%" >套餐信息</th>
				
				<th width="8%" >费率(被叫/回铃)</th>
				<th width="5%" >推荐</th>
				<th width="10%" align="center">选项</th>
				
			</tr>
		</thead>
		<tbody>
			<?php foreach ($item as $k=>$v):?>
			<tr target="id" rel="<?php echo $v->id?>">
				<td><input name="ids[]" value="<?php echo $v->id?>" type="checkbox"></td>
				<td><?php echo $v->agent->acctname?></td>
				<td><?php echo $v->acctname?></td>
				<td><?php echo $v->password?></td>
				<td><?php echo $v->user_attribStr().'/'.$v->user_vipstr();?>
				<?php if($v->user_vipstr()):?>
					<a href="<?php echo url('users/vips')?>/acctid/<?php echo $v->id?>/flag/1" target="ajaxTodo" title="确认关闭吗!确认后将立即生效！">关VIP</a>
					<?php else:?>
					<a href="<?php echo url('users/vips')?>/acctid/<?php echo $v->id?>/flag/0" target="ajaxTodo" title="确认开通VIP吗?">开VIP</a>
					
					<?php endif;?>
					<?php if($v->callpwd == 0):?>
					<a href="<?php echo url('users/callpwd')?>/acctid/<?php echo $v->id?>/flag/1" target="ajaxTodo" title="确认改为加密呼叫吗？操作后，无密码呼叫接口将被阻断">加密呼叫</a>
					<?php else:?>
					<a href="<?php echo url('users/callpwd')?>/acctid/<?php echo $v->id?>/flag/0" target="ajaxTodo" title="确认改为普通呼叫吗?修改后,无需密码即可呼叫。">普通呼叫</a>
					<?php endif;?>
				</td>
				<td><?php echo $v->bindnum();?>(<?php echo $v->bind_ipphone?>) </td>
				<td><?php echo $v->enable == 1 ?'正常':'<font color=red>冻结</font>';?></td>
				<td><?php echo $v->balance;?></td>
				<td><a href="<?php echo url('web/web800set',array('id'=>$v->id))?>" target="dialog">800设置</a> <a href="<?php echo url('cbquick/index',array('acctname'=>$v->acctname))?>" target="navTab" mask="true" rel="<?php echo md5($v->acctname.'——亲亲')?>" title="亲亲号设置-<?php echo $v->acctname?>" >亲亲号设置</a></td>
				<td><?php echo $v->activedate?>/<?php echo $v->expireddate;?></td>
				<td>
				<?php 
				$userpackage = Userpackage::find('userid = ?',$v->id)->setColumns('id,packagename,minte')->getOne();
				if ($userpackage->id())
				{
					echo "{$userpackage->packagename}({$userpackage->minte}分钟)";
				}else{
					echo '';
				}
				?>
				</td>
				
				<td><?php echo $v->a_rategroup->rategroupname.'/'.$v->b_rategroup->rategroupname?></td>
				<td><?php echo h($v->unionacctname);?></td>
				<td>
				<!--  
					<a href="<?php echo url('userbindtel',array('_userid'=>$v->id),null,array('mode'=>'standard'));?>" target="navTab" rel="page2">绑定电话</a>
				-->
					<a href="<?php echo url($delete)?>/ids/<?php echo $v->id?>" target="ajaxTodo" title="确认删除吗?">删除</a>
					<a href="<?php echo url('users/authen_billtime')?>/uid/<?php echo $v->id?>" target="ajaxTodo" title="确认查询该用户最大通话时长吗?查询此时间可以确认用户通话状态！">最大通话时长</a>
				</td>
			</tr>
			<?php endforeach;?>
		</tbody>
	</table>
	<div class="panelBar">
			<div class="pages">
			<span>显示</span>
			<select name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
				<option value="20" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==20)echo 'selected=selected';?>>20</option>
				<option value="50" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==50)echo 'selected=selected';?>>50</option>
				<option value="100" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==100)echo 'selected=selected';?>>100</option>
				<option value="200" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==200)echo 'selected=selected';?>>200</option>
				<?php if ($_SESSION['acct']['acclevel'] == 0):?>
				<option value="5000" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==5000)echo 'selected=selected';?>>5000</option>
				<option value="10000" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==10000)echo 'selected=selected';?>>10000</option>
				<?php endif;?>
			</select>
				<span>共 <?php echo $pagination['record_count'];?> 条</span>
			</div>
		
		<div class="pagination" targetType="navTab" totalCount="<?php echo $pagination['record_count'];?>" numPerPage="<?php echo $pagination['page_size'];?>" pageNumShown="10" currentPage="<?php echo $pagination['current'];?>" ></div>

	</div>
</div>